import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'radio/WeChecklist.dart';

/*
 * 膳食页面食物显示的item
 * image: 食物item 图片
 * objectId: 食物id
 * title: 食物标题
 * onChan: 选中事件
 * price: 价格
 */

typedef OnChangeBack = void Function(List<String> value);

class FoodItemWidget extends StatelessWidget {
  final String image;
  final String objectId;
  final String title;
  final OnChangeBack onChange;
  final String price;

  const FoodItemWidget(
      {Key key,
      this.image,
      @required this.objectId,
      @required this.title,
      this.onChange,
      @required this.price})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.centerLeft,
      child: Stack(
        children: <Widget>[
          Container(
            width: ScreenUtil().setWidth(180),
            height: ScreenUtil().setHeight(120),
            margin: EdgeInsets.all(10),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(15)),
              boxShadow: [
                BoxShadow(
                    color: Color(0xFFeaedf2),
                    offset: Offset(5.0, 5.0),
                    blurRadius: 10.0,
                    spreadRadius: 2.0),
                BoxShadow(color: Color(0xffeef1f4), offset: Offset(1.0, 1.0)),
                BoxShadow(color: Color(0xfffbfcfd))
              ],
            ),
          ),
          Positioned(
            left: ScreenUtil().setWidth(15),
            right: ScreenUtil().setWidth(15),
            child: Container(
                width: ScreenUtil().setWidth(180),
                height: ScreenUtil().setHeight(170),
                child: Column(
                  children: <Widget>[
                    Container(
                        width: ScreenUtil().setWidth(150),
                        height: ScreenUtil().setWidth(101),
                        decoration: BoxDecoration(
                            boxShadow: [
                              BoxShadow(
                                  color: Color(0xFFeaedf2),
                                  offset: Offset(5.0, 5.0),
                                  blurRadius: 10.0,
                                  spreadRadius: 2.0),
                              BoxShadow(
                                  color: Color(0xffeef1f4),
                                  offset: Offset(1.0, 1.0)),
                              BoxShadow(color: Color(0xfffbfcfd)),
                            ],
                            borderRadius: BorderRadius.all(Radius.circular(17)),
                            image: new DecorationImage(
                                image: image != null
                                    ? NetworkImage(image)
                                    : AssetImage('images/Rectangle.png'),
                                fit: BoxFit.none)),),
                    Container(
                      color: Colors.transparent,
                      height: ScreenUtil().setHeight(39),
//                      width: ScreenUtil().setWidth(170),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                              Container(
                                color: Colors.transparent,
                                width: ScreenUtil().setWidth(165),
                                child: WeChecklist(
                                  onChange: onChange,
                                  children: [
                                    WeChecklistItem(
                                      label: title,
                                      value: objectId,
                                      labelColor: 0xff154D7C,
                                    )
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  ],
                )),
          )
        ],
      ),
    );
  }
}
